package com.litaomn.fang;
import android.os.ICustomService;
import android.os.RemoteException;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;

import com.litaomn.fang.hotload.server.CustomService;

import java.util.HashMap;
import java.util.Map;


public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final EditText ed = findViewById(R.id.host);
        Button button = findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ICustomService client = CustomService.getClient();
                if (client != null) {
                    String host = ed.getEditableText().toString();
                    Map map = new HashMap();
                    map.put("host", host);
                    map.put("port", "9002");
                    try {
                        client.execCommond("connect", map);
                    } catch (RemoteException e) {
                        e.printStackTrace();
                    }
                }
            }
        });

        Button button2 = findViewById(R.id.button2);
        button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                try {
                    CustomService.getClient().execCommond("send", new HashMap());
                } catch (RemoteException e) {
                    e.printStackTrace();
                }
            }
        });

    }



}
